package GuiClasses;
/**
 * TCSS 360 - Project
 */
import java.util.Observable;
import java.util.Observer;

import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.JLabel;
import javax.swing.JPanel;

import objectClasses.User;
import objectClasses.Attendees;
/**
 *  A generic panel class that extends Observable.
 *  
 *  @author Abraham Santini
 */
abstract class GenericPanel extends Observable{
	/**
	 * The observer object that this class will notify.
	 */
	protected Observer my_o_ver;
	/**
	 * A JPanel to hold all of the objects that the various child classes will need.
	 */
	protected JPanel my_panel;
	
	
	/**
	 * Public constructor for the GenericPanel class.
	 * @param the_o_er The Observer object that this calls will notify.
	 */
	public GenericPanel(Observer the_o_er) {
		my_panel = new JPanel();
		my_o_ver = the_o_er;
		addObserver(my_o_ver);
		my_panel.setLayout(new BoxLayout(my_panel, BoxLayout.Y_AXIS));
		
		
		// create welcome panel with user name
		JPanel welcomePanel = new JPanel();
		welcomePanel.setLayout(new BoxLayout(welcomePanel, BoxLayout.X_AXIS));
		welcomePanel.add(new JLabel("Welcome " + ((Attendees)GuiMain.getUser()).getUsername())); // need a getName method
		welcomePanel.add(Box.createHorizontalGlue());
		my_panel.add(welcomePanel);
	}
	
	/**
	 * Returns the class' JPanel
	 * @return my_panel The panel that holds the user specific objects.
	 */
	public JPanel getPanel() {
		return my_panel;
	}
	
}
